accountingIntegrationDashboardApp.controller('maintenanceGeographyCtrl', ['$scope', '$http', '$log', 'serverDataService', function ($scope, $http, $log, serverDataService){ 

    $scope.countries = [];
    $scope.geographyGroups = [];

    $scope.entityName = 'geography';

    $scope.setChildScope($scope);

    $scope.renderRecordsFromServer();

    $scope.loadCountries = function(){
        return $scope.countries.length ? null : serverDataService.getEntityList('country', false)
                .then(function (data){
                    $scope.countries = data.gridRecords;
                });
    };

    $scope.loadGeographyGroups = function(){
        return $scope.geographyGroups.length ? null : serverDataService.getEntityList('geography-group', false)
                .then(function (data){
                    $scope.geographyGroups = data.gridRecords;
                });
    };

    $scope.addGeography = function() {
        $scope.inserted = {
          id: null,
          code: null,
          externalCode: null,
          description: null
        };
        $scope.gridRecords.push($scope.inserted);
    };
}]);